package com.hy.net

import android.util.Log
import com.hy.net.model.Banner
import com.hy.net.net.MyRetrofit
import com.hy.net.net.requestWanAndroid

/**
 * @Description:
 * @Author: wdk
 * @CreateTime: 2024/6/1 22:03
 */
class MainRepository {
    companion object {
        private const val TAG = "MainRepository"
    }

    val api: HomeApiService by lazy { MyRetrofit.create(HomeApiService::class.java) }

    /**
     * 如果想要拿到回调的失败信息，
     * 1、参数中可以传入LiveData,或者返回一个
     */
    suspend fun getHomeBanner(): MutableList<Banner>? {
        val data = requestWanAndroid(requestCall = {
            api.getHomeBanner()
        }, errorBlock = { code, error, response ->
            Log.e(TAG, "getHomeBanner: code=$code  error=$error")
        })
        return data
    }
}